<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>私人导游入住</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<style>
.userDetailCen input {border:none;}
</style>
<body>
<div id="aaa"></div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">私人导游入住管理</div>
                <div class="layui-card-body">
                    <div class="layui-form-item layui-form">

                        <div class="layui-inline">
                            <label class="layui-form-label">申请人姓名</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" id="name_" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">申请人手机</label>
                            <div class="layui-input-block">
                                <input type="text" name="guide_tel" id="guide_tel_" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">审核状态</label>
                            <div class="layui-input-block">
                                <select name="is_pass" lay-filter="aihao" id="is_pass">
                                    <option value=""></option>
                                    <option value="0">审核中</option>
                                    <option value="1">通过</option>
                                    <option value="2">不通过</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-btn-group test-table-operate-btn">
                                <button class="layui-btn" data-type="searchUserButton">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                    <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate">
                    </table>
                    <script type="text/html" id="test-table-operate-barDemo">
					   <a class="layui-btn layui-btn-xs" lay-event="showDetail">详细信息</a> 
                        <a class="layui-btn layui-btn-xs" lay-event="showPic">身份证照片</a>
                        <a class="layui-btn layui-btn-normal layui-btn-xs" id="showImg" lay-event="showImg">导游证照片</a>
                        {{# if(d.is_pass==0){ }}
                        <a class="layui-btn layui-bg-green layui-btn-xs" lay-event="yesPass">审核</a>
                        {{# }else if(d.is_pass==1){ }}
                        <a class=" layui-btn layui-btn-disabled layui-btn-xs">通过</a>
                        {{# } else if(d.is_pass==2){ }}
                        <a class="layui-btn layui-btn-disabled layui-btn-xs">不通过</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<!--导游信息详情-->
<div id="userDetail" style="display: none;padding:20px;">
    <div class="userDetailCen">
          <form class="layui-form" action="" lay-filter="component-form-group"> 
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机号 :</label>
                            <div class="layui-input-block">
                                <input  type="text" id="guide_tel"   class="layui-input" value="">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">银行卡号 :</label>
                            <div class="layui-input-block">
                                <input type="text" id="guide_card"    class="layui-input"  >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">开户行 :</label>
                            <div class="layui-input-block">
                                <input type="text" id="guide_open_bank"   class="layui-input" >
                            </div>
                        </div> 
						    <div class="layui-form-item">
                            <label class="layui-form-label">导游证照片 :</label>
                            <div class="layui-input-block">
                              <img src="">    
							</div>
                        </div>  
                    </form>
    </div>
</div>
<div id="contentShow" style="display:none;padding: 30px;">
    <p id="consultation"></p>
</div>

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate','set'], function(){
        $ = layui.jquery;
        var table = layui.table
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form;

        table.render({
            elem: '#test-table-operate'
            ,url: "{:url('Live/guide')}"
            ,height: 'full-100'
            ,cols: [[
                {field:'guide_id',width:80,align:'center', title: 'ID'}
                ,{field:'name',align:'center',title: '申请人姓名'}
				,{field:'guide_tel',align:'center',title: '申请人手机号'}
                ,{field:'cardid',align:'center',title: '身份证号'}
                ,{field:'app_time',align:'center',title: '申请时间'}
                ,{align:'center',width:350, title: '操作', toolbar: '#test-table-operate-barDemo'}
            ]]
            ,page:true
            ,limit:20
        });

        form.render(null,'component-form-group');

        laydate.render({
            elem: '#search_time'
        });

        //监听工具条
        table.on('tool(test-table-operate)', function(obj){
            var data = obj.data; 
			if(obj.event === 'showDetail'){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var guide_id = data.guide_id; 
                $.ajax({
                    url: "{:url('Live/guidedetail')}",
                    type: 'post',
                    dataType: 'json',
                    data: {guide_id:guide_id},
                    success: function(data){
                        layer.close(loading);
                        if (data.code === 0) { 
						console.log(data.data.guide_tel);
                            if(data.data.guide_tel==""){
                                $('#guide_tel').val('未设置');
                            }else{
                                $('#guide_tel').val(data.data.guide_tel);
                            }
                            if(data.data.guide_card ==""){
                                $('#guide_card').html('未设置');
                            }else{
                                $('#guide_card').val(data.data.guide_card);
                            }
                            if(data.data.guide_open_bank==''){
                                $('#guide_open_bank').val('未设置');
                            }else{
                                $('#guide_open_bank').val(data.data.guide_open_bank);
                            }
                            if(data.data.guide_card_name==''){
                                $('#guide_card_name').val('未设置');
                            }else{
                                $('#guide_card_name').val(data.data.guide_card_name);
                            } 

                            var userDetailModal = layer.open({
                                title:'导游详情'
                                ,type: 1
                                ,shadeClose: true
                                ,area:['500px']
                                ,content: $('#userDetail')
                            });
                        }else{
                            layer.msg('获取信息失败',{icon:2,time:1000});
                        }


                    }
                })
            }
            else if(obj.event === 'showPic'){
                if (!data.guide_card_img){
                    layer.msg('暂无图片',{time:1000});
                    return false;
                }
                var img_src = data.guide_card_img;
                var img_src_arr = img_src.split(',');

                var img_src_data = {};
                img_src_data.title = '身份证图片';
                img_src_data.id = data.id;
                img_src_data.start = 0;
                img_src_data.data =[];

                var src = {};

                for(var i=0;i<img_src_arr.length;i++){
                    src = {};
                    var num = i+1;
                    src.alt = '身份证图片'+ num;
                    src.pid = i;
                    src.src = img_src_arr[i];
                    src.thumb = img_src_arr[i];
                    //console.log(src);
                    img_src_data.data.push(src);
                }
                //console.log(img_src_data);
                layer.photos({
                    photos: img_src_data
                    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                });
            } else if(obj.event === 'showImg'){
                if (!data.guide_pic){
                    layer.msg('暂无图片',{time:1000});
                    return false;
                }
                var img_src = data.guide_pic;
                var img_src_arr = img_src.split(',');

                var img_src_data = {};
                img_src_data.title = '导游证件照片';
                img_src_data.id = data.id;
                img_src_data.start = 0;
                img_src_data.data =[];

                var src = {};

                for(var i=0;i<img_src_arr.length;i++){
                    src = {};
                    var num = i+1;
                    src.alt = '导游证件照片'+ num;
                    src.pid = i;
                    src.src = img_src_arr[i];
                    src.thumb = img_src_arr[i];
                   // console.log(src);
                    img_src_data.data.push(src);
                }
                layer.photos({
                    photos: img_src_data
                    ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                });
            }else if(obj.event === 'yesPass'){
                layer.confirm('导游入住申请',{
                    btn: ['通过', '不通过', '取消']
                    ,yes:function(){
                        var loading = layer.load(1, {
                            shade: [0.1,'#fff'] //0.1透明度的白色背景
                        });
                        $.ajax({
                            url: "{:url('Live/guideIsPass')}",
                            type: 'post',
                            dataType: 'json',
                            data: {id:data.guide_id,uid:data.uid,tel:data.guide_tel,is_pass:1},
                            success: function(msg){
                                layer.close(loading);
                                if (msg === 0) {
                                    layer.msg('已通过', {icon: 1, time: 1000},function(){
                                        window.location.reload();
                                    });
                                }else{
                                    layer.msg('系统错误',{icon:2,time:1000});
                                }
                            }
                        });
                    }
                    ,btn2:function(){
                        var loading = layer.load(1, {
                            shade: [0.1,'#fff'] //0.1透明度的白色背景
                        });
                        $.ajax({
                            url: "{:url('Live/guideIsPass')}",
                            type: 'post',
                            dataType: 'json',
                            data: {id: data.guide_id,tel:data.guide_tel,uid:data.uid, is_pass:2},
                            success: function (msg) {
                                layer.close(loading);
                                if (msg === 0) {
                                    layer.msg('未通过', {icon: 1, time: 1000},function(){
                                        window.location.reload();
                                    });
                                } else {
                                    layer.close(loading);
                                    layer.msg('系统错误', {icon: 2, time: 1000});
                                }
                            }
                        })
                    }
                    ,btn3:function(){
                        layer.closeAll();
                    }
                });
            }

        });

        var $ = layui.$, active = {
            searchUserButton:function(){
                var name  = $('#name_').val();
                var tel = $('#guide_tel_').val();
                var is_pass = $('#is_pass').val();

                table.reload('test-table-operate', {
                    where: {
                        name:name,
                        guide_tel: tel,
                        is_pass:is_pass
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
                //return false;
            }
        };
        //绑定点击事件
        $('.test-table-operate-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>